package kordegi.forumsystem.mapper;

import kordegi.forumsystem.entity.Comment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CommentMapper {
    public List<Comment> getAllCommentList(Long articleId);

    @Insert("insert into forum_comment(id, user_id, title, description, content) values (#{id}, #{user_id}, #{title}, #{description}, #{content})")
    int addComment(Comment comment);

    @Update("update forum_comment set Comment_Num = #{current_Num} where id = #{id}")
    int updateLikeCount(int currentNum, Long id);

    int updateComment(Comment comment);

    int deleteComment(Long id);

    int selectCount(@Param("id") Long id,@Param("parentId") Long parentId);

    @Select("select * from forum_comment where id = #{id}")
    Comment getById(Long id);

    @Select("select id from forum_comment where parentId = #{id}")
    Long getParentId(Long id);

    @Select("select id from forum_comment where id = #{id}")
    Long getId(Long id);

    @Select("select * from forum_comment where parentId = #{id}")
    Comment getByParentId(Long id);

}
